<?php
namespace Resmodel;

use Model\LanguageAwareInterface;
use Zend\Db\Adapter\Adapter;
use Zend\Db\Sql\Expression;
use Zend\Db\Sql\Predicate\Like;
use Zend\Db\Sql\Predicate\Operator;
use Zend\Db\Sql\Select;
use Zend\InputFilter\InputFilter;

class DishTagTable extends ResAbstractTable implements LanguageAwareInterface
{
    private $_lang;

    /**
     * @param $id
     * @return DishTag
     */
    public function getDishTag($id){
       return $this->getById($id);
    }



    /**
     * @return InputFilter
     */
    public function getInputFilter()
    {
        $filter = new InputFilter();


        return $filter;
    }

    public function getLang()
    {
        return $this->_lang;
    }

    public function setLang($lang)
    {
        $this->_lang = $lang;
    }

    public function getDistinctTags()
    {
        $select = $this->getDbSqlSelect();
        $select->columns(array('tag'=> new Expression('DISTINCT(tag)')))
            ->where(array('lang'=>$this->getLang()));
        return $this->executeSelectForArray($select);
    }

    public function getAllTagsByDishId($id)
    {
        return $this->getTableGateway()->select(
            array('dish_id'=>$id, 'lang'=>$this->getLang()));
    }


}